<template>
  <div class="client-app">
    <!-- 顶部导航 -->
    <header class="app-header">
      <h1>客户中心</h1>
      <div class="header-actions">
        <button class="message-btn">
          <img
src="@/assets/message-icon.png" alt="消息" />
          <span v-if="unreadCount > 0"
class="badge">{{ unreadCount }}</span>
        </button>
      </div>
    </header>

    <!-- 主内容区 -->
    <main class="app-main">
      <router-view />
    </main>

    <!-- 底部导航 -->
    <nav class="app-tabbar">
      <router-link v-for="tab in tabs"
:key="tab.path" :to="tab.path" class="tab-item">
        <img
:src="tab.icon" :alt="tab.title" />
        <span>{{ tab.title }}</span>
      </router-link>
    </nav>
  </div>
</template>

<script setup>
  import { ref } from 'vue'

  const unreadCount = ref(2)

  const tabs = ref([
    {
      title: '首页',
      path: '/home',
      icon: '@/assets/home-icon.png',
    },
    {
      title: '合同',
      path: '/contracts',
      icon: '@/assets/contract-icon.png',
    },
    {
      title: '案件',
      path: '/cases',
      icon: '@/assets/case-icon.png',
    },
    {
      title: '消息',
      path: '/messages',
      icon: '@/assets/message-icon.png',
    },
    {
      title: '我的',
      path: '/me',
      icon: '@/assets/user-icon.png',
    },
  ])
</script>

<style scoped lang="scss">
  .client-app {
    display: flex;
    flex-direction: column;
    height: 100vh;

    .app-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 12px 15px;
      background: white;
      box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);

      h1 {
        font-size: 18px;
        font-weight: bold;
        margin: 0;
      }

      .header-actions {
        button {
          background: none;
          border: none;
          position: relative;

          img {
            width: 22px;
            height: 22px;
          }

          .badge {
            position: absolute;
            top: -5px;
            right: -5px;
            background: #ff4d4f;
            color: white;
            font-size: 10px;
            min-width: 16px;
            height: 16px;
            line-height: 16px;
            text-align: center;
            border-radius: 8px;
            padding: 0 3px;
          }
        }
      }
    }

    .app-main {
      flex: 1;
      overflow-y: auto;
      padding-bottom: 50px;
    }

    .app-tabbar {
      display: flex;
      background: white;
      border-top: 1px solid #f0f0f0;
      padding: 5px 0;

      .tab-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-decoration: none;
        color: #666;
        font-size: 12px;

        img {
          width: 24px;
          height: 24px;
          margin-bottom: 3px;
        }

        &.router-link-active {
          color: #1989fa;
        }
      }
    }
  }
</style>
